/**
 * This is used to modify requirejs when in use with chrome extension conent scripts
 *
 * As content scripts can't access tabs, the backround file must be used to support injecting
 * scripts into pages
 */

"use strict";

require.load = function (moduleName, contextName) {
    var url = require.nameToUrl(moduleName, null, contextName);
    var    context = require.s.contexts[contextName];
    require.s.isDone = false;
    context.loaded[moduleName] = false;

    //chrome.tabs.executeScript(null, {file:url});
    chrome.extension.sendRequest({
        'obj':'tab',
        'url':url
    },
    function(){
        //there seems to be an issue with the fact that it may not have been fully evaluated at the time
        //of the callback. this is a really bad fix
        context.loaded[moduleName] = true; 
    });
};

/**
 * I am not sure if this should be here... but still
 */
require({
    baseUrl: ''
});

